<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:sec="http://www.similarworld.com/security/tag"
	template="/WEB-INF/templates/template.xhtml">
	<ui:define name="content">
		<sec:isAuthenticated>
			<h:form>
				<p:wizard widgetVar="wizard" showNavBar="false">

					<p:tab id="category" title="Category">

						<p:panel header="Category Insert">

							<h:messages errorClass="error" />

							<h:panelGrid columns="2">
								<p:dataTable id="categoryTable" var="category"
									value="#{homeBean.categories}">
									<p:column headerText="Category Name">
										<h:outputText value="#{category.caption}" />
									</p:column>

									<p:column headerText="Description">
										<h:outputText value="#{category.description}" />
									</p:column>

									<p:column headerText="status">
										<h:outputText value="#{category.status}" />
									</p:column>

									<p:column headerText="Select And Forward">
										<p:commandButton disabled="#{category.status eq 'PENDING'}"
											id="selectCategoryButton" icon="ui-icon-circle-arrow-e"
											oncomplete="wizard.next()" value="Select and Forward">
											<f:setPropertyActionListener value="#{category}"
												target="#{homeBean.selectedCategory}" />
										</p:commandButton>
									</p:column>
								</p:dataTable>
								<p:panel>
									<h:outputText value="Category Name:" />
									<h:inputText value="${homeBean.category.caption}" />
									<h:outputText value="Category Description:" />
									<h:inputText value="${homeBean.category.description}" />
									<p:commandButton id="addCategoryButton" ajax="false" value="Add"
										action="#{homeBean.saveCategory}" icon="ui-icon-circle-plus" />
								</p:panel>
							</h:panelGrid>
						</p:panel>
					</p:tab>
					
					<p:tab id="item" title="Item">

						<p:panel header="Item Insert To #{homeBean.selectedCategory.caption}">

							<p:messages autoUpdate="true" />

							<h:panelGrid columns="2">
								<p:dataTable id="itemTable" var="item"
									value="#{homeBean.items}">
									<p:column headerText="Item Name">
										<h:outputText value="#{item.caption}" />
									</p:column>

									<p:column headerText="Description">
										<h:outputText value="#{item.description}" />
									</p:column>

									<p:column headerText="status">
										<h:outputText value="#{item.status}" />
									</p:column>
									
									<p:column headerText="Category">
										<h:outputText value="#{item.category.caption}" />
									</p:column>

									<p:column headerText="Select And Forward">
										<p:commandButton disabled="#{item.status eq 'DELETED'}"
											id="selectItemButton" icon="ui-icon-circle-arrow-e"
											oncomplete="wizard.next()" value="Select and Forward">
											<f:setPropertyActionListener value="#{item}"
												target="#{homeBean.selectedItem}" />
										</p:commandButton>
									</p:column>
								</p:dataTable>
								<p:panel>
																	
									<h:outputText value="Item Name:" />
									<h:inputText value="${homeBean.item.caption}" />
									
									<h:outputText value="Item Desctiption :" />
									<h:inputText value="${homeBean.item.description}" />
									
									<h:outputText value="Item Stars :" />
									<p:rating value="${homeBean.itemRate}" stars="10"/>
									
									<p:commandButton id="addItemButton" value="Add" ajax="false"
										action="#{homeBean.saveItem}" icon="ui-icon-circle-plus" />
								</p:panel>
							</h:panelGrid>
						</p:panel>
					</p:tab>

				</p:wizard>
			</h:form>
		</sec:isAuthenticated>

	</ui:define>
</ui:composition>
